<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Option-Mixins</title>
    <link rel="stylesheet" href="../../../assets/css/bootstrap.min.css">
    <script src="../../../assets/js/vue-2.5.6.js"></script>
</head>

<body>
    <div id="app">
        <p>num:{{ num }}</p>
        <P><button @click="add">增加数量</button></P>
    </div>
</body>
<script>
    //额外临时加入时，用于显示日志
    var addLog = {
        updated: function() {
            console.log("数据放生变化,变化成" + this.num + ".");
        }
    }
    var app = new Vue({
        el: "#app",
        data: {
            num: 1
        },
        methods: {
            add: function() {
                this.num++;
            }
        },
        mixins: [addLog] //混入
    })
</script>

</html>